<?php

class Model_Ps_Orderhistory extends Zend_Db_Table_Abstract {

	protected $_name = 'ps_order_history';
	protected $_adaptor = 'db_remote';
	protected $_primary = 'id_order_history';
	
	public function getOrderhistory( $idOrderHistory){
		
		$row = $this->fetchRow("`id_order_history` = ". $idOrderHistory);
		if(!$row) return false;
		return $row->toArray();		
		
		}
		
	public function addOrderhistory( $idEmployee , $idOrder , $idOrderState , $dateAdd){
		
		$data = array(
			
         "id_employee" =>  $idEmployee ,
         "id_order" =>  $idOrder ,
         "id_order_state" =>  $idOrderState ,
         "date_add" =>  $dateAdd 
	
			);
		$this->insert($data);
		
		}
		
	public function updateOrderhistory(  $idOrderHistory ,  $idEmployee , $idOrder , $idOrderState , $dateAdd){
		$data = array(
			
         "id_employee" =>  $idEmployee ,
         "id_order" =>  $idOrder ,
         "id_order_state" =>  $idOrderState ,
         "date_add" =>  $dateAdd 
	
			);
			
		$this->update($data,"`id_order_history` = ". $idOrderHistory);
		}
		
	public function deleteOrderhistory( $idOrderHistory){
		
		$this->delete("`id_order_history` = ". $idOrderHistory);
		
		}	
	
	public function listAll(){
		
		$rows =$this->fetchAll("1","id_order_history DESC ");
		if(!$rows) return false;
		return $rows->toArray();			
		
		}	
}


?>